
package edu.hm.devcamp.presentation.activities;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import edu.hm.devcamp.R;

public class HelpView extends Activity implements OnClickListener {

    private int mHelp = -1;

    private Button mHelpButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.help);

        RelativeLayout rl = (RelativeLayout)findViewById(R.id.help_layout);
        rl.setOnClickListener(this);

        mHelpButton = (Button)findViewById(R.id.help_text);
        mHelpButton.setOnClickListener(this);
        showText();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.help_layout:
                this.finish();
                break;
            case R.id.help_text:
                showText();
                break;
        }
    }

    private void showText() {
        String[] tips = getResources().getStringArray(R.array.help);
        mHelp++;
        if (mHelp >= tips.length) {
            mHelp = 0;
        }

        // change the background if needed
        if (mHelp != 0) {
            mHelpButton.setBackgroundResource(R.drawable.help_flat);
        } else {
            mHelpButton.setBackgroundResource(R.drawable.help);
        }            

        mHelpButton.setText(tips[mHelp]);
    }
}
